<!--
 * @FileDescription 碰撞检测区域设置
 * @Author 杨宇翔
 * @Date 20220531 15:24:25
 * @LastEditors 杨宇翔
 * @LastEditTime 20220531 15:24:25
-->
<template>
    <div class="detection-area-configuration">
        <div class="container">
            <div class="header">
                <span>碰撞检测区域设置</span>
                <span class="material-icons" @click="UsageComponent.Default.NavigateToPreviousAsync()">×</span>
            </div>

            <div class="content">
                <div class="grid-item">
                    <input type="checkbox" name="碰撞检测区域设置" id="是否使能配置" hidden v-model="configuration.Activation">
                    <label for="是否使能配置">
                        <span></span>
                        <span>是否使能配置</span>
                    </label>

                    <input type="checkbox" name="碰撞检测区域设置" id="坐标是否有效" hidden v-model="configuration.CoordinatesValid">
                    <label for="坐标是否有效">
                        <span></span>
                        <span>坐标是否有效</span>
                    </label>
                </div>
                <div class="grid-item">
                    <span class="fs16 colorwhite">区域ID</span>
                    <input type="number" name="碰撞检测区域设置" id="区域ID" min="0" max="7" step="1"
                        v-model="configuration.RegionID">
                </div>
                <div class="grid-item">
                    <span class="fs16 colorwhite">P1 X坐标:</span>
                    <input type="number" name="碰撞检测区域设置" id="P1 X坐标" min="-500.0" max="1138.2" step="0.2"
                        v-model="configuration.Point1X">
                </div>
                <div class="grid-item">
                    <span class="fs16 colorwhite">P1 Y坐标:</span>
                    <input type="number" name="碰撞检测区域设置" id="P1 Y坐标" min="-204.6" max="204.8" step="0.2"
                        v-model="configuration.Point1Y">
                </div>
                <div class="grid-item">
                    <span class="fs16 colorwhite">P2 X坐标:</span>
                    <input type="number" name="碰撞检测区域设置" id="P2 X坐标" min="-500.0" max="1138.2" step="0.2"
                        v-model="configuration.Point2X">
                </div>
                <div class="grid-item">
                    <span class="fs16 colorwhite">P2 Y坐标:</span>
                    <input type="number" name="碰撞检测区域设置" id="P2 Y坐标" min="-204.6" max="204.8" step="0.2"
                        v-model="configuration.Point2Y">
                </div>
            </div>

            <div class="button-container">
                <button class="reset" type="button" @click="state = true">
                    <span>显示示意图</span>
                </button>
                <button class="reset" type="button"
                    @click="CollisionComponent.Default.SetCollisionRegionAsync(configuration.Activation, configuration.CoordinatesValid, configuration.RegionID, configuration.Point1X, configuration.Point1Y, configuration.Point2X, configuration.Point2Y)">
                    <span>保存配置</span>
                </button>
            </div>
        </div>

        <div class="sketch-map" v-show="state">
            <div class="header">
                <span>示意图</span>
                <span class="material-icons" @click="state = false">×</span>
            </div>
            <img src="/static/MMWR/标定说明001.png">
        </div>
    </div>
</template>

<script setup lang="ts">
import { ClientMessage } from '@runtime/generate/message/ClientMessage';
import { reactive, ref, UnwrapNestedRefs } from 'vue';
import { CollisionComponent, UsageComponent } from './MMWRComponent';
const configuration: UnwrapNestedRefs<ClientMessage.MillimeterWaveRadarCollisionRegionConfiguration> = reactive(new ClientMessage.MillimeterWaveRadarCollisionRegionConfiguration(false, false, 0, '-50', '0', '50', '200'));

const state = ref(false);
</script>

<style scoped>
.detection-area-configuration {
    position: absolute;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;

    backdrop-filter: blur(1rem);
}

.container {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);

    width: 80rem;
    height: 40rem;

    display: flex;
    flex-direction: column;
    align-items: stretch;

    border-radius: 2rem;
    border: solid 0.6rem transparent;
    background-image: linear-gradient(#131620, #131620),
        linear-gradient(90deg, #218cde, #807de1);
    background-origin: border-box;
    background-clip: content-box, border-box;
}

.header {
    width: 100%;

    padding: 2rem;

    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header>span:first-of-type {
    color: white;
    font-size: 2.4rem;
    font-weight: 500;
}

.header>.material-icons {
    color: #81859C;
    font-size: 3.6rem;
}

.content {
    padding-left: 4rem;
    padding-right: 4rem;

    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr 1fr;
    gap: 1rem 8rem;
}

.grid-item {
    height: 3.6rem;

    display: flex;
    justify-content: space-between;
    align-items: center;
}

.grid-item:nth-of-type(1),
.grid-item:nth-of-type(2) {
    height: 4.6rem;
    padding-bottom: 1rem;
}

.grid-item>span {
    color: #B1B1D4;
    font-size: 1.6rem;
}

input {
    width: 24rem;
    height: 3.6rem;

    border: none;
    outline: none;

    color: #B1B1D4;
    font-size: 1.6rem;

    padding-left: 1.5rem;

    background-color: transparent;

    border-radius: 0.6rem;
    border: 0.1rem solid #36384B;
}

input::-webkit-inner-spin-button,
input::-webkit-outer-spin-button {
    display: none;
}

label {
    display: inline-flex;

    justify-content: flex-start;
    align-items: center;
    gap: 1rem;
}

label>span:first-of-type {
    display: inline-block;
    width: 1.6rem;
    height: 1.6rem;

    background-image: url('/static/MMWR/ic_checkbox_normal.png');
}

input:checked+label>span:first-of-type {
    background-image: url('/static/MMWR/ic_checkbox_select.png');
}

label>span:last-of-type {
    color: #81859C;
    font-size: 1.6rem;
}

.button-container {
    width: 100%;

    margin: auto;

    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4rem;
}

.button-container>button {
    width: 25rem;
    height: 10rem;

    background-image: url('/static/MMWR/btn-bg.png');
    background-repeat: no-repeat;
    background-position-y: -0.5rem;
}

.button-container>button>span {
    color: white;
    font-size: 3rem;
}

.sketch-map {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);

    display: flex;
    flex-direction: column;
    align-items: stretch;

    border-radius: 2rem;
    border: solid 0.6rem transparent;
    background-image: linear-gradient(#131620, #131620),
        linear-gradient(90deg, #218cde, #807de1);
    background-origin: border-box;
    background-clip: content-box, border-box;
}

img {
    margin: 4rem;
    border-radius: 2rem;
}
</style>